import java.util.Scanner;

public class Test3 {

    public static void main(String[] args) throws InterruptedException {
        Object obj = new Object();
        Thread t1 = new Thread(()->{
           synchronized (obj) {
               System.out.println("t1线程等待之前");
               try {
                   obj.wait();
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
               System.out.println("t线程等待之后");
           }
        });
        Thread t2 = new Thread(()->{
            Scanner in = new Scanner(System.in);
            synchronized (obj) {
                System.out.print("t2通知之前");
                in.nextInt();
                obj.notify();
                System.out.println("t2通知之后");
            }
        });

        t2.start();
        Thread.sleep(500);
        t1.start();
    }
}
